-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New directional_navigation_overrides example combining auto dir nav w/ manual overrides
#22405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New directional_navigation_overrides example combining auto dir nav w/ manual overrides
#22405
Conversation
it-me-joda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that I personally would rather have each navigation mode in a separate example. Then maybe a third that demonstrates that you could combine them? This current state is overwhelming at first glance. I think I would have examples like:
ui/navigation/
auto-navigation
manual-navigation
combined-navigation
But that's just my personal opinion. I'd be curious to see what others think about it.
|
I agree with @it-me-joda here, with the emphasis in the third example focusing on how and why to use overrides. |
159b127 to
fc1c24d
Compare
8709d09 to
425a63b
Compare
navigation example combining auto and manual directional navcombined_navigation example combining auto and manual directional nav
|
I incorporated @viridia ’s scenario as the page 2 of buttons ,and I inverted vertical navigation in page 3 to demonstrate a whimsy override. The updated screen recording (which is also available in the description) is hereScreen.Recording.2026-01-13.at.1.46.09.AM.mov |
alice-i-cecile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, this is starting to look good!
There's a few notes on pedagogical structure:
- Automatic directional navigation should be the default for 99% of users; the example should be renamed to simply
directional_navigation. - Now that it exists, the
manual_navigationexample is misleading: no one should be doing this. It should be removed completely. - The primary point of manual navigation is now for overriding edge cases produced by automatic directional navigation. The example name and module docs providing context should be reworked to reflect that; perhaps
directional_navigation_overrides.rs?
The setup and content of the new example are quite nice though; I have no complaints there! Lots of boilerplate to set up the complex layout, but I'm happy with how clear it is.
39207ce to
f246aeb
Compare
|
@alice-i-cecile I agree with your structure notes and implemented them. I also went over the comments in the modules and updated them to the best of my ability to make the recommended uses clearer and the interactions with each other clearer I’m happy with the example now too :) feels comprehensive |
combined_navigation example combining auto and manual directional navdirectional_navigation_overrides example combining auto dir nav w/ manual overrides
alice-i-cecile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better! That's much clearer to users IMO.
BTW, you can doc-link your structs in the module docs of examples. This is mildly nice to do, because then they break when we rename things :)
it-me-joda
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the split. If there is any advanced use cases I think we could add more examples later but this looks good to me
| .insert_resource(AutoNavigationConfig { | ||
| // Require at least 10% overlap in perpendicular axis for cardinal directions | ||
| min_alignment_factor: 0.1, | ||
| // Don't connect nodes more than 200 pixels apart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the docs for this field, it should be specific about how the distance is measured.
Maybe could mention here that the distance is from closest edge to closest edge, not center to center.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice now, I don't see any problems. Switching to multi page navigation was a great idea.
Objective
bevy_input_focus: No example demonstrates how to use theDirectionalNavigationMapand automatic navigation together #22299Solution
directional_navigation_overrides(examples/ui/navigation/directional_navigation_overrides.rs) that demonstrates both auto navigation and manually defining edges via theDirectionalNavigationMap. The example uses the previous auto navigation example (now atexamples/ui/navigation/directional_navigation.rs) as a base. It creates pages ofAutoDirectionalNavigationbuttons depicting different scenarioes where manual navigation is needed to create a desired experience.Testing
cargo run --example directional_navigation_overrides. Screen recording attached.cargo run --example directional_navigationShowcase
Screen Recording
Screen.Recording.2026-01-13.at.1.46.09.AM.mov